<template>
	<view class="apps">
		<view class="flex fdc  ptb20 plr20">
			<view class="flex bgwhite plr20 ptb20 br15" v-if="user.id > 0">
				<uv-avatar :src="user.avatar" size="50"></uv-avatar>
				<view class="f1 flex fdc jcc ml20 f14">
					<view class="f16 mr20 mb10 fweight4">{{user.nickname}}</view>
					<view class="flex aic">
						<view class="f14" v-if="user.group_id == '3'">至尊会员</view>
						<view class="f14" v-else>普通会员</view>
					</view>
				</view>
			</view>
			<view class="flex aic bgwhite plr20 ptb20 br15" @click="handle('/pages/member/login','nav',false)" v-else>
				<uv-avatar size="60" 
				src="">
				</uv-avatar>
				<view class="f1 flex  ml20 f14">暂未登录，点击登录</view>
			</view>
			<view class="flex br15 mt20 bgwhite ptb10 plr10">
				<div class="bgcard" style="width: 690rpx; height: 345rpx;" v-if="user.group_id == '3'">
					<image :src="cardImage" style="width:690rpx;height: 345rpx;z-index: 2; position: absolute;top:0;left:0;"></image>
					<div class="flex pt30 plr20 zindex-2 bgcard aic">
						<view class="f1 flex f13 white">有效期：{{user.auth_end}}</view>
						<view class="plr10 f16 white">编号:{{user.id}}</view>
					</div>
					<div class="flex pt30 plr20 zindex-2 bgcard mt20">
						<view class="f1 flex"></view>
						<view class="plr10 f16 white flex fdc">
							<view class="mt20 f13">会员积分：{{user.score}}</view>
							<view class="mt20 f13">预约时长：{{user.subscribe_time_long}}</view>
						</view>
					</div>
				</div>
				<div class="flex bgcard" @click="handle('/pages/sale/goods?id=5','nav',false)" v-else>
					<image :src="vcImage" style="width:690rpx;height: 115rpx;z-index: 10;"></image>
				</div>
				
			</view>
			
		</view>

		<view class="flex fdc mt20 plr20 ptb20 mlr20 bgwhite">
			<view class="flex aic ptb10 bdb1s bceee" @click="handle('/pages/order/index','nav',true)">
				<uv-icon name="gift-fill" size="60rpx" color="#a82022"></uv-icon>
				<view class="f14 f1 ml10 c666">我的订单</view>
			</view>
			<view class="flex aic ptb10 bdb1s bceee" @click="handle('/pages/member/subscribe','nav',true)">
				<uv-icon name="integral-fill" size="60rpx" color="#a82022">
				</uv-icon>
				<view class="f14 f1 ml10 c666">预约记录</view>
			</view>
			<view class="flex aic ptb10 bdb1s bceee" @click="handle('/pages/member/notice','nav',true)">
				<uv-icon name="chat-fill" size="60rpx" color="#a82022">
				</uv-icon>
				<view class="f14 f1 ml10 c666">我的消息</view>
			</view>
			<button class="btn flex aic ptb10 bdb1s bceee jcl bgwhite" open-type="contact">
				<uv-icon name="weixin-fill"  size="60rpx" color="#a82022"></uv-icon>
				<view class="f14 flex f1 ml10 c666">微信客服</view>
			</button>
			<view class="flex aic ptb10 bdb1s bceee" @click="openMap()">
				<uv-icon name="map-fill"  size="60rpx" color="#a82022"></uv-icon>
				<view class="f14 f1 ml10 c666">在线导航</view>
			</view>
		</view>
	</view>
</template>

<script>
	let app;
	import { timeFormat } from '@/uni_modules/uv-ui-tools/libs/function/index.js'
	import { util } from '/common/util.js'
	export default {
		data() {
			return {
				user:{
					id:0,
					score:0,
					subscribe_time_long:0,
				},
				cardImage:"https://ball.lifecloud.top/static/card.jpg",
				vcImage:"https://ball.lifecloud.top/static/vc.jpg",
			}
		},
		onLoad(){
			app = this;
			this.userInfo();
		},
		onShow(){
			this.userInfo();
		},
		methods: {
			openMap(){
				uni.openLocation({
					latitude:42.78245,
					longitude:93.746664,
					name:'新疆融合体育中心',
					address:'哈密市伊州区红星·中奥体育公园',
					scale:14
				})
			},
			async userInfo(){
				const data = await util.request({url:"/mpwechat/userinfo"});
				if(data.code == 200){
					app.user = data.data;
					app.user.auth_end = data.data.auth_end ?timeFormat(data.data.auth_end,'yyyy-mm-dd'):"";
				}
			},
			handle (page,type,is_login){
				if(is_login){
					if(util.isLogin() == false){
						uni.setStorageSync('remount_url',JSON.stringify({page:page,type:type,login:is_login}));
						uni.navigateTo({
							url:'/pages/member/login',
						})
						return;
					}
				}
				if(type == 'nav'){
					uni.navigateTo({
						url: page,
					});
					return;
				}
				if(type== 'switch'){
					uni.switchTab({
						url:page
					})
					return;
				}
			}
		}
	}
</script>

<style scoped>
	.bgcard{position: relative;}
	.order{background-color: #f9f9f9;}
	.btn{background-color: #fff ;border-radius:0;line-height:auto !important;font-size: 14px !important;display: flex;padding:10rpx 0; margin:0; color:#666;}
	.btn::after{border:none !important; padding:0 !important;}
</style>
